$(document).ready(function() {
	//初始化页面宽度和高度
	pageResize();
	$("body").click(function(event){  
		if(!checkLogin()){return false;}
	});  
	displayTable();

	$("#btn_showImg").click(function() {
		document.getElementById("div_listTable").style.display = "none";
		document.getElementById("div_imgTable").style.display = "block";
	});

	$("#btn_showList").click(function() {
		document.getElementById("div_imgTable").style.display = "none";
		document.getElementById("div_listTable").style.display = "block";

	});
	
	 
	
	 $("#datetimepicker").datetimepicker({
	yearOffset:0,
	lang:'ch',
	timepicker:false,
	format:'d/m/Y',
	formatDate:'Y/m/d',
	/*minDate:'-1970/01/02', // yesterday is minimum date
	maxDate:'+1970/01/02' // and tommorow is maximum date calendar*/
	});
	
	
	$("#select1").change(function(){
			var p1=$(this).children('option:selected').val();
			alert(p1);
			
			$("#select2").append("<option> </option>");
			$("#select2").append('<option>'+ p1 + '</option>');
			
	});
	

	
	

});

function displayTable() {
	$("#listTable").bootstrapTable({
		columns: [{
			field: 'registerNumber',
			title: '总登记号',
			align: 'center'
		}, {
			field: 'classifyNumber',
			title: '分类号',
			align: 'center'
		}, {
			field: 'collectionName',
			title: '名称',
			align: 'center'
		}, {
			field: 'classify',
			title: '类别',
			align: 'center'
		}, {
			field: 'accountNumber',
			title: '数量',
			align: 'center'
		}, {
			field: 'source',
			title: '来源',
			align: 'center'
		}, {
			field: 'dynasty',
			title: '时代',
			align: 'center'
		}],
		url: "data/listdata.json",
		striped: true, //是否显示间隔色
		//search: true,  //是否显示搜索框功能
		pagination: true, //是否分页
		//showRefresh: true, //是否显示刷新功能 
	});

	$("#imgTable").bootstrapTable({
		columns: [{
			//title: "img1",
			//visible: false, //使title不可见
			field: 'img1',
			align: 'center',
			formatter: "img_formatter",
		}, {
			//title: "img2",
			field: 'img2',
			align: 'center',
			formatter: "img_formatter",
		}, {
			//title: "img3",
			field: 'img3',
			align: 'center',
			formatter: "img_formatter",
		}, {
			//title: "img4",
			field: 'img4',
			align: 'center',
			formatter: "img_formatter",
		}, {
			//title: "img5",
			field: 'img5',
			align: 'center',
			formatter: "img_formatter",
		}, {
			//title: "img6",
			field: 'img6',
			align: 'center',
			formatter: "img_formatter",
		}, ],
		url: "data/imgdata.json",
		//striped:true,//是否显示间隔色
		//search: true,  //是否显示搜索框功能
		pagination: true, //是否分页
		//showRefresh: true, //是否显示刷新功能
		pageSize: 2, //每页的记录行数（*）
		pageList: [2, 5], //可供选择的每页的行数（*）
	});

}

//value为json数据中key-value对应的value值，row
function img_formatter(value, row, index) {
	console.log("img1 formatter calling,value: " + value + " row: " + row.img1);
	var result = "";
	result = '<img border="0" src="img/' + value + '.png"/>';
	return result;
}